package com.google.code.nexttraffic.web.action;

import java.util.List;

import com.google.code.nexttraffic.service.impl.TerminalServiceImpl;
import com.google.code.nexttraffic.web.model.Passterminal;
import com.google.code.nexttraffic.web.model.Terminal;
import com.google.code.nexttraffic.web.model.Terminal_Temp;
import com.google.code.nexttraffic.web.model.Timetable;

public class SearchAction {

	private Integer startTerminal;

	private Integer endTerminal;

	private String linkTerminal;

	private String linkPasTerminal;

	private String divsion;

	private String distance;

	private String totalTime;

	private String PassTerminalYN;

	private List<Terminal> terminals;

	private List<Timetable> timetables;

	private List<Passterminal> passterminals;

	private List<Terminal_Temp> terminalTemps;

	private TerminalServiceImpl service = TerminalServiceImpl.getInstance();

	public String simpleSearch() throws Exception {

		Terminal_Temp temp = new Terminal_Temp();
		temp.setStartTerminal(startTerminal);
		temp.setEndTerminal(endTerminal);
		temp.setDivsion("시외");

		setTerminalTemps(service.search(temp));

		return "success";
	}

	public String detailSearchView() throws Exception {

		return "success";

	}

	public String detailSearch() throws Exception {

		Terminal_Temp temp = new Terminal_Temp();
		temp.setStartTerminal(startTerminal);
		temp.setEndTerminal(endTerminal);
		
		if(divsion.equals("1")){
			divsion="시외";
		}
		if(divsion.equals("2")){
			divsion="고속";
		}
		if(divsion.equals("3")){
			divsion="혼합";
		}
		temp.setDivsion(divsion);

		setTerminalTemps(service.search(temp));

		return "success";

	}

	public Integer getStartTerminal() {
		return startTerminal;
	}

	public void setStartTerminal(Integer startTerminal) {
		this.startTerminal = startTerminal;
	}

	public Integer getEndTerminal() {
		return endTerminal;
	}

	public void setEndTerminal(Integer endTerminal) {
		this.endTerminal = endTerminal;
	}

	public String getLinkTerminal() {
		return linkTerminal;
	}

	public void setLinkTerminal(String linkTerminal) {
		this.linkTerminal = linkTerminal;
	}

	public String getLinkPasTerminal() {
		return linkPasTerminal;
	}

	public void setLinkPasTerminal(String linkPasTerminal) {
		this.linkPasTerminal = linkPasTerminal;
	}

	public String getDivsion() {
		return divsion;
	}

	public void setDivsion(String divsion) {
		this.divsion = divsion;
	}

	public String getDistance() {
		return distance;
	}

	public void setDistance(String distance) {
		this.distance = distance;
	}

	public String getTotalTime() {
		return totalTime;
	}

	public void setTotalTime(String totalTime) {
		this.totalTime = totalTime;
	}

	public String getPassTerminalYN() {
		return PassTerminalYN;
	}

	public void setPassTerminalYN(String passTerminalYN) {
		PassTerminalYN = passTerminalYN;
	}

	public List<Terminal> getTerminals() {
		return terminals;
	}

	public void setTerminals(List<Terminal> terminals) {
		this.terminals = terminals;
	}

	public List<Timetable> getTimetables() {
		return timetables;
	}

	public void setTimetables(List<Timetable> timetables) {
		this.timetables = timetables;
	}

	public List<Passterminal> getPassterminals() {
		return passterminals;
	}

	public void setPassterminals(List<Passterminal> passterminals) {
		this.passterminals = passterminals;
	}

	public TerminalServiceImpl getService() {
		return service;
	}

	public void setService(TerminalServiceImpl service) {
		this.service = service;
	}

	public List<Terminal_Temp> getTerminalTemps() {
		return terminalTemps;
	}

	public void setTerminalTemps(List<Terminal_Temp> terminalTemps) {
		this.terminalTemps = terminalTemps;
	}

}
